***IJPOR
***21 August  2018
*** replication and corrections


***use  use "C:\Users\Jessica\Desktop\pol knowledge MPSA 2015\IJPOR\data\20180821 with placement.dta", clear


***generate the standardized items
***remember that 2039 items are in opposite direction! more distance!
egen z_Z3036_1= std(Z3036_1)
egen z_Z3036_2= std(Z3036_2)
egen z_Z3036_3= std(Z3036_3)
egen z_A2037 = std(A2037)
egen z_A2038 = std(A2038)
egen z_A2039 = std(A2039)
egen z_A2039_B = std(A2039_B)



***TABLE 1 requires MACRO GAP data
*** some cases are problematic and were dropped.
***macro level data used in there
*** "C:\Users\Jessica\Desktop\pol knowledge MPSA 2015\IJPOR\data\macrogap.dta" 

replace macroGAPZ3036_2 =. if macroGAPZ3036_2 ==0

graph dot (mean) macroGAPZ3036, over(Z1004) nofill
graph dot (mean) macroGAPZ3036_2, over(Z1004) nofill
graph dot (mean) macroGAPZ3036_3, over(Z1004) nofill
graph dot (mean) macroGAPZ3037, over(Z1004) nofill
graph dot (mean) macroGAPZ3038, over(Z1004) nofill
graph dot (mean) macroGAPZ3039, over(Z1004) nofill
graph dot (mean) macroGAPZ3039_B, over(Z1004) nofill


***TABLE 2 requires a factor of STD data.
***factor
**use full set
) z_A2039_B, by (Z1004)

pwcorr z_Z3036_1 z_Z3036_2 z_Z3036_3 z_A2037 z_A2038 z_A2039 z_A2039_B, sig


factor z_Z3036_1 z_Z3036_2 z_Z3036_3 z_A2037 z_A2038 z_A2039 z_A2039_B
factor z_Z3036_1 z_Z3036_2 z_Z3036_3 z_A2037 z_A2038 z_A2039 z_A2039_B, mineigen(1)
paran z_Z3036_1 z_Z3036_2 z_Z3036_3 z_A2037 z_A2038 z_A2039 z_A2039_B, iter(5000)

factor z_Z3036_1 z_Z3036_2 z_Z3036_3 z_A2037 z_A2038 z_A2039 z_A2039_B, mineigen(1)
rotate

***removing items without variance because of no DK offered.
replace z_Z3036_2=. if Z1004=="AUS_1996"
replace z_Z3036_2=. if Z1004=="CHE_2011"
replace z_Z3036_2=. if Z1004=="CZE_1996"
replace z_Z3036_2=. if Z1004=="DEU_2005"
replace z_Z3036_2=. if Z1004=="ESP_1996"
replace z_Z3036_2=. if Z1004=="ESP_2008"
replace z_Z3036_2=. if Z1004=="ISR_1996"
replace z_Z3036_2=. if Z1004=="MEX_1997"
replace z_Z3036_2=. if Z1004=="MEX_2000"
replace z_Z3036_2=. if Z1004=="POL_1997"
replace z_Z3036_2=. if Z1004=="ROU_1996"
replace z_Z3036_2=. if Z1004=="SWE_2002"

***removing items without variance because of no DK offered.
replace Z3036_2=. if Z1004=="AUS_1996"
replace Z3036_2=. if Z1004=="CHE_2011"
replace Z3036_2=. if Z1004=="CZE_1996"
replace Z3036_2=. if Z1004=="DEU_2005"
replace Z3036_2=. if Z1004=="ESP_1996"
replace Z3036_2=. if Z1004=="ESP_2008"
replace Z3036_2=. if Z1004=="ISR_1996"
replace Z3036_2=. if Z1004=="MEX_1997"
replace Z3036_2=. if Z1004=="MEX_2000"
replace Z3036_2=. if Z1004=="POL_1997"
replace Z3036_2=. if Z1004=="ROU_1996"
replace Z3036_2=. if Z1004=="SWE_2002"


***factors by country and country year
**no variance no DK in _2
factor z_Z3036_1 z_Z3036_3 z_A2037 z_A2038 z_A2039 z_A2039_B if Z1004=="AUS_1996", mineigen(1)
rotate

factor z_Z3036_1 z_Z3036_2 z_Z3036_3 z_A2037 z_A2038 z_A2039 z_A2039_B if Z1004=="AUS_2004", mineigen(1)
rotate

factor z_Z3036_1 z_Z3036_2 z_Z3036_3 z_A2037 z_A2038 z_A2039 z_A2039_B if Z1004=="AUS_2007", mineigen(1)
rotate

factor z_Z3036_1 z_Z3036_2 z_Z3036_3 z_A2037 z_A2038 z_A2039 z_A2039_B if Z1004=="AUT_2008", mineigen(1)
rotate

factor z_Z3036_1 z_Z3036_2 z_Z3036_3 z_A2037 z_A2038 z_A2039 z_A2039_B if Z1004=="AUT_2013", mineigen(1)
rotate

factor z_Z3036_1 z_Z3036_2 z_Z3036_3 z_A2037 z_A2038 z_A2039 z_A2039_B if Z1004=="BRA_2002", mineigen(1)
rotate

factor z_Z3036_1 z_Z3036_2 z_Z3036_3 z_A2037 z_A2038 z_A2039 z_A2039_B if Z1004=="BRA_2006", mineigen(1)
rotate

factor z_Z3036_1 z_Z3036_2 z_Z3036_3 z_A2037 z_A2038 z_A2039 z_A2039_B if Z1004=="BRA_2010", mineigen(1)
rotate

factor z_Z3036_1 z_Z3036_2 z_Z3036_3 z_A2037 z_A2038 z_A2039 z_A2039_B if Z1004=="CAN_1997", mineigen(1)
rotate

factor z_Z3036_1 z_Z3036_2 z_Z3036_3 z_A2037 z_A2038 z_A2039 z_A2039_B if Z1004=="CAN_2004", mineigen(1)
rotate

factor z_Z3036_1 z_Z3036_2 z_Z3036_3 z_A2037 z_A2038 z_A2039 z_A2039_B if Z1004=="CAN_2008", mineigen(1)
rotate

factor z_Z3036_1 z_Z3036_2 z_Z3036_3 z_A2037 z_A2038 z_A2039 z_A2039_B if Z1004=="CHE_1999", mineigen(1)
rotate

factor z_Z3036_1 z_Z3036_2 z_Z3036_3 z_A2037 z_A2038 z_A2039 z_A2039_B if Z1004=="CHE_2003", mineigen(1)
rotate

factor z_Z3036_1 z_Z3036_2 z_Z3036_3 z_A2037 z_A2038 z_A2039 z_A2039_B if Z1004=="CHE_2007", mineigen(1)
rotate

**no variance no DK in _2
factor z_Z3036_1  z_Z3036_3 z_A2037 z_A2038 z_A2039 z_A2039_B if Z1004=="CHE_2011", mineigen(1)
rotate

**no variance no DK in _2
factor z_Z3036_1  z_Z3036_3 z_A2037 z_A2038 z_A2039 z_A2039_B if Z1004=="CZE_1996", mineigen(1)
rotate

factor z_Z3036_1 z_Z3036_2 z_Z3036_3 z_A2037 z_A2038 z_A2039 z_A2039_B if Z1004=="CZE_2002", mineigen(1)
rotate

factor z_Z3036_1 z_Z3036_2 z_Z3036_3 z_A2037 z_A2038 z_A2039 z_A2039_B if Z1004=="CZE_2006", mineigen(1)
rotate

factor z_Z3036_1 z_Z3036_2 z_Z3036_3 z_A2037 z_A2038 z_A2039 z_A2039_B if Z1004=="CZE_2010", mineigen(1)
rotate

factor z_Z3036_1 z_Z3036_2 z_Z3036_3 z_A2037 z_A2038 z_A2039 z_A2039_B if Z1004=="DEU_1998", mineigen(1)
rotate

**no variance no DK in _2
factor z_Z3036_1 z_Z3036_3 z_A2037 z_A2038 z_A2039 z_A2039_B if Z1004=="DEU_2005", mineigen(1)
rotate

factor z_Z3036_1 z_Z3036_2 z_Z3036_3 z_A2037 z_A2038 z_A2039 z_A2039_B if Z1004=="DEU_2009", mineigen(1)
rotate

**no variance no DK in _2
factor z_Z3036_1 z_Z3036_3 z_A2037 z_A2038 z_A2039 z_A2039_B if Z1004=="ESP_1996", mineigen(1)
rotate

factor z_Z3036_1 z_Z3036_2 z_Z3036_3 z_A2037 z_A2038 z_A2039 z_A2039_B if Z1004=="ESP_2004", mineigen(1)
rotate

**no variance no DK in _2
factor z_Z3036_1 z_Z3036_3 z_A2037 z_A2038 z_A2039 z_A2039_B if Z1004=="ESP_2008", mineigen(1)
rotate

factor z_Z3036_1 z_Z3036_2 z_Z3036_3 z_A2037 z_A2038 z_A2039 z_A2039_B if Z1004=="FIN_2003", mineigen(1)
rotate

factor z_Z3036_1 z_Z3036_2 z_Z3036_3 z_A2037 z_A2038 z_A2039 z_A2039_B if Z1004=="FIN_2007", mineigen(1)
rotate

factor z_Z3036_1 z_Z3036_2 z_Z3036_3 z_A2037 z_A2038 z_A2039 z_A2039_B if Z1004=="FIN_2011", mineigen(1)
rotate

factor z_Z3036_1 z_Z3036_2 z_Z3036_3 z_A2037 z_A2038 z_A2039 z_A2039_B if Z1004=="FRA_2002", mineigen(1)
rotate

factor z_Z3036_1 z_Z3036_2 z_Z3036_3 z_A2037 z_A2038 z_A2039 z_A2039_B if Z1004=="FRA_2007", mineigen(1)
rotate

factor z_Z3036_1 z_Z3036_2 z_Z3036_3 z_A2037 z_A2038 z_A2039 z_A2039_B if Z1004=="FRA_2012", mineigen(1)
rotate

**no variance no DK in _2
factor z_Z3036_1 z_Z3036_3 z_A2037 z_A2038 z_A2039 z_A2039_B if Z1004=="ISR_1996", mineigen(1)
rotate

factor z_Z3036_1 z_Z3036_2 z_Z3036_3 z_A2037 z_A2038 z_A2039 z_A2039_B if Z1004=="ISR_2003", mineigen(1)
rotate

factor z_Z3036_1 z_Z3036_2 z_Z3036_3 z_A2037 z_A2038 z_A2039 z_A2039_B if Z1004=="ISR_2006", mineigen(1)
rotate

**no variance no DK in _2
factor z_Z3036_1 z_Z3036_3 z_A2037 z_A2038 z_A2039 z_A2039_B if Z1004=="MEX_1997", mineigen(1)
rotate

**no variance no DK in _2
factor z_Z3036_1 z_Z3036_3 z_A2037 z_A2038 z_A2039 z_A2039_B if Z1004=="MEX_2000", mineigen(1)
rotate

factor z_Z3036_1 z_Z3036_2 z_Z3036_3 z_A2037 z_A2038 z_A2039 z_A2039_B if Z1004=="MEX_2003", mineigen(1)
rotate

factor z_Z3036_1 z_Z3036_2 z_Z3036_3 z_A2037 z_A2038 z_A2039 z_A2039_B if Z1004=="MEX_2006", mineigen(1)
rotate

factor z_Z3036_1 z_Z3036_2 z_Z3036_3 z_A2037 z_A2038 z_A2039 z_A2039_B if Z1004=="MEX_2009", mineigen(1)
rotate

factor z_Z3036_1 z_Z3036_2 z_Z3036_3 z_A2037 z_A2038 z_A2039 z_A2039_B if Z1004=="MEX_2012", mineigen(1)
rotate

factor z_Z3036_1 z_Z3036_2 z_Z3036_3 z_A2037 z_A2038 z_A2039 z_A2039_B if Z1004=="NLD_1998", mineigen(1)
rotate

factor z_Z3036_1 z_Z3036_2 z_Z3036_3 z_A2037 z_A2038 z_A2039 z_A2039_B if Z1004=="NLD_2002", mineigen(1)
rotate

factor z_Z3036_1 z_Z3036_2 z_Z3036_3 z_A2037 z_A2038 z_A2039 z_A2039_B if Z1004=="NLD_2006", mineigen(1)
rotate

factor z_Z3036_1 z_Z3036_2 z_Z3036_3 z_A2037 z_A2038 z_A2039 z_A2039_B if Z1004=="NLD_2010", mineigen(1)
rotate

factor z_Z3036_1 z_Z3036_2 z_Z3036_3 z_A2037 z_A2038 z_A2039 z_A2039_B if Z1004=="NOR_2001", mineigen(1)
rotate

factor z_Z3036_1 z_Z3036_2 z_Z3036_3 z_A2037 z_A2038 z_A2039 z_A2039_B if Z1004=="NOR_2005", mineigen(1)
rotate

factor z_Z3036_1 z_Z3036_2 z_Z3036_3 z_A2037 z_A2038 z_A2039 z_A2039_B if Z1004=="NOR_2009", mineigen(1)
rotate

factor z_Z3036_1 z_Z3036_2 z_Z3036_3 z_A2037 z_A2038 z_A2039 z_A2039_B if Z1004=="NZL_1996", mineigen(1)
rotate

factor z_Z3036_1 z_Z3036_2 z_Z3036_3 z_A2037 z_A2038 z_A2039 z_A2039_B if Z1004=="NZL_2002", mineigen(1)
rotate

factor z_Z3036_1 z_Z3036_2 z_Z3036_3 z_A2037 z_A2038 z_A2039 z_A2039_B if Z1004=="NZL_2008", mineigen(1)
rotate

factor z_Z3036_1 z_Z3036_2 z_Z3036_3 z_A2037 z_A2038 z_A2039 z_A2039_B if Z1004=="NZL_2011", mineigen(1)
rotate

**no variance no DK in _2
factor z_Z3036_1 z_Z3036_3 z_A2037 z_A2038 z_A2039 z_A2039_B if Z1004=="POL_1997", mineigen(1)
rotate

factor z_Z3036_1 z_Z3036_2 z_Z3036_3 z_A2037 z_A2038 z_A2039 z_A2039_B if Z1004=="POL_2001", mineigen(1)
rotate

**no variance no DK in _2
factor z_Z3036_1 z_Z3036_3 z_A2037 z_A2038 z_A2039 z_A2039_B if Z1004=="POL_2005", mineigen(1)
rotate

factor z_Z3036_1 z_Z3036_2 z_Z3036_3 z_A2037 z_A2038 z_A2039 z_A2039_B if Z1004=="POL_2007", mineigen(1)
rotate

factor z_Z3036_1 z_Z3036_2 z_Z3036_3 z_A2037 z_A2038 z_A2039 z_A2039_B if Z1004=="PRT_2002", mineigen(1)
rotate

factor z_Z3036_1 z_Z3036_2 z_Z3036_3 z_A2037 z_A2038 z_A2039 z_A2039_B if Z1004=="PRT_2005", mineigen(1)
rotate

factor z_Z3036_1 z_Z3036_2 z_Z3036_3 z_A2037 z_A2038 z_A2039 z_A2039_B if Z1004=="PRT_2009", mineigen(1)
rotate

factor z_Z3036_1 z_Z3036_2 z_Z3036_3 z_A2037 z_A2038 z_A2039 z_A2039_B if Z1004=="ROM_2009", mineigen(1)
rotate

***no variance no DK in _2
factor z_Z3036_1 z_Z3036_3 z_A2037 z_A2038 z_A2039 z_A2039_B if Z1004=="ROU_1996", mineigen(1)
rotate

factor z_Z3036_1 z_Z3036_2 z_Z3036_3 z_A2037 z_A2038 z_A2039 z_A2039_B if Z1004=="ROU_2004", mineigen(1)
rotate

factor z_Z3036_1 z_Z3036_2 z_Z3036_3 z_A2037 z_A2038 z_A2039 z_A2039_B if Z1004=="ROM_2009", mineigen(1)
rotate


factor z_Z3036_1 z_Z3036_2 z_Z3036_3 z_A2037 z_A2038 z_A2039 z_A2039_B if Z1004=="SWE_1998", mineigen(1)
rotate

***no variance no DK in _2
factor z_Z3036_1 z_Z3036_3 z_A2037 z_A2038 z_A2039 z_A2039_B if Z1004=="SWE_2002", mineigen(1)
rotate

factor z_Z3036_1 z_Z3036_2 z_Z3036_3 z_A2037 z_A2038 z_A2039 z_A2039_B if Z1004=="SWE_2006", mineigen(1)
rotate

***CI operations
ci z_Z3036_1 z_Z3036_2 z_Z3036_3 z_A2037 z_A2038 z_A2039 z_A2039_B if Z2002==2
ci z_Z3036_1 z_Z3036_2 z_Z3036_3 z_A2037 z_A2038 z_A2039 z_A2039_B if Z2002==1

***trying variables
generate gender diff = (z_Z3036_1 if Z2002=1)-(z_Z3036_1 if Z2002=2)


***by country only 
keep if Z1004=="CAN_1997"
pwmean z_Z3036_1, over(Z2002)
pwmean z_Z3036_2, over(Z2002)
pwmean z_Z3036_3, over(Z2002)

***overall graphs with CI (Figures 1 and 1b) 
ciplot Z3036_1 Z3036_2 Z3036_3  , inclusive by(Z2002) level(99)
***overall graphs with CI (Figures 1 and 1b) 
ciplot z_Z3036_1 z_Z3036_2 z_Z3036_3  , inclusive by(Z2002) level(99)


***two last items need a reversal!!!
generate newZ2039_B= z_A2039_B/-1
generate new_Z2039= z_A2039/-1
ciplot z_A2037 z_A2038 new_Z2039 newZ2039_B , inclusive  by(Z2002) level(99)

ci z_A2037 z_A2038 new_Z2039 newZ2039_B if Z2002==1
ci z_A2037 z_A2038 new_Z2039 newZ2039_B if Z2002==2
